/*
 * @version: 1.0
 * @Author: zhl
 * @Date: 2021-09-01 14:15:44
 * @LastEditors: zhl
 * @LastEditTime: 2021-09-30 08:56:33
 * @Description: file content
 */
#ifndef __GET_RESPONSE_H__
#define __GET_RESPONSE_H__

#include <stdint.h>
#include <string>

#include "Data.h"
#include "dlt698_frame.h"

typedef enum _GET_RESPONSE_TYPE{
    GET_RESPONSE_NORMAL       = 1,    //读取一个对象属性的响应
    GET_RESPONSE_NORMAL_LIST  = 2,    //读取若干个对象属性的响应
    GET_RESPONSE_RECORD       = 3,    //读取一个记录型对象属性的响应
    GET_RESPONSE_RECORD_LIST  = 4,    //读取若干个记录型对象属性的响应
    GET_RESPONSE_NEXT         = 5,    //读取分帧传输的下一帧的响应
    GET_RESPONSE_MD5          = 6     //读取一个对象属性的 MD5 值的响应
}GET_RESPONSE_TYPE;

typedef struct _TDATA{
    std::string oad;
    std::string value;
}TDATA;



class GetResponse{

    public:
        GetResponse();
        ~GetResponse();


        static GetResponse &getInstance();
        int parse_response(int64_t item_id, uint8_t *apdu, int len, std::list<Data> &result);
        int parse_error_response(int64_t dev_id, uint8_t *apdu, int len);
    
    private:
        uint8_t  PIID;
        static GetResponse c_instance;

        int parse_response_normal(int64_t dev_id, uint8_t *data, int len, std::list<Data> &result);
        int parse_response_normal_list(int64_t dev_id, uint8_t *data, int len, std::list<Data> &result);
        int parse_response_next(int64_t dev_id, uint8_t *data, int len, std::list<Data> &result);
        int parse_data(int64_t dev_id, uint8_t *data, int len, std::list<Data> &result);
        int get_items(uint8_t *data, int len, int &offset, Data &value);

};





#endif /* __GET_RESPONSE_H__ */
